$(function(){
	var tel = '';
	$("#tel").blur(function(){
		if($(this).val().match(/^1([358][0-9]|4[57]|7[0135678])\d{8}$/) == null){
			tel = false;
		}else{
			tel = true;
		}
	})
	// PC端信息提交
	$('.btn-submit button.submit').click(function(){
		var name = $('#username').val();
		var mobile = $('#tel').val();
		var intention = $('#idea').val();
		if(name && mobile && intention && tel){
			var url = "https://cloud.kaaction.com/kaaction/api/v1/owIntentionApi/intention";
			$.ajax({
				url:url,
				type:"post",
				dataType:"json",
			    data:{
					name:name,
					mobile:mobile,
					intention:intention
				},
				success:function(res){
					$('p.want').text('信息提交成功！');
					$('#username').val('');
					$('#tel').val('');
					$('#idea').val('');
				}
			})
		}else{
			$('p.want').text('请填写正确的信息！')
			return false;
		}
	})
	// 移动端信息提交
	var mobtel = '';
	$("#mobtel").blur(function(){
		if($(this).val().match(/^1([358][0-9]|4[57]|7[0135678])\d{8}$/) == null){
			mobtel = false;
		}else{
			mobtel = true;
		}
	})

	$('.mob-btn-submit button.submit').click(function(){
		var mobname = $('#mobusername').val();
		var mobmobile = $('#mobtel').val();
		var mobintention = $('#mobidea').val();
		if(mobname && mobmobile && mobintention && mobtel){
			var url = "https://cloud.kaaction.com/kaaction/api/v1/owIntentionApi/intention";
			$.ajax({
				url:url,
				type:"post",
				dataType:"json",
			    data:{
					name:mobname,
					mobile:mobmobile,
					intention:mobintention
				},
				success:function(res){
					$('p.mob-want').text('信息提交成功！');
					$('#mobusername').val('');
					$('#mobtel').val('');
					$('#mobidea').val('');
				}
			})
		}else{
			$('p.mob-want').text('请填写正确的信息！')
			return false;
		}
	})
	//手机端的菜单列表
	$('img.menu,div.menulist a img').click(function(){
		$('.menulist img.floor').toggleClass('nolist');	
		$('.facetop').toggleClass('face');	
	})
})